package com.youlai.system.controller;


import com.youlai.system.common.result.Result;
import com.youlai.system.model.entity.AttendanceDeductionSetting;
import com.youlai.system.model.form.AttendanceLeaveSettingForm;
import com.youlai.system.service.IAttendanceDeductionSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 只茂瑞
 * @since 2024-06-24
 */
@RestController
@RequestMapping("/attendance-deduction-setting")
@Tag(name = "17.考勤管理扣款设置接口")
@RequiredArgsConstructor
public class AttendanceDeductionSettingController {

    private final IAttendanceDeductionSettingService attendanceDeductionSettingService;
    @Operation(summary = "根据部门id获取扣款设计")
    @GetMapping("/{id}/form")
    public Result<List<AttendanceDeductionSetting>> getAttendanceDeductionSetting(
            @Parameter(description = "部门id") @PathVariable Long id
    ) {
        List<AttendanceDeductionSetting> attendanceDeductionSettings = attendanceDeductionSettingService.getDeductionSettingForm(id);
        return Result.success(attendanceDeductionSettings);
    }

    @Operation(summary = "修改扣款设置")
    @PostMapping("/updateDeductionStatus")
    public Result updateDeductionStatus(@RequestBody AttendanceDeductionSetting attendanceDeductionSetting){
        Integer id = attendanceDeductionSettingService.updateAttendUpdateDeductionStatus(attendanceDeductionSetting);
        return Result.success(id);
    }

}
